#include "component/GameComponent.h"
#include "GameObject.h"
#include "Messenger.h"
#include "event/Event_GameObject_NewComponent.h"



using namespace Boon;

Boon::GameComponent::GameComponent( const char* compName, Boon::GameObject* g )
	: Object( compName ),
	  m_GameObject( g ),
	  m_Enabled( true )
{
	Event_GameObject_NewComponentStrong e( new Event_GameObject_NewComponent( m_GameObject->GetUniqueObjectID() ) );
	Messenger::GetInstance().Bang( e );
}

GameObject& Boon::GameComponent::GetGameObject() const
{
	return *m_GameObject;
}

void Boon::GameComponent::SetEnabled( bool flag )
{
	GetGameObject().SetComponentEnabled( flag, this );
	m_Enabled = flag;
}

void Boon::GameComponent::Destroy()
{
	m_GameObject->Destroy( GetComponentID() );
}

bool Boon::operator==( const GameComponent& lfs, const GameComponent& rhs )
{
	if( &lfs == &rhs )
		return true;
	return false;
}
